/*
 * Copyright © 2021 http://www.hn-szzy.com/ All rights reserved.
 */
package com.xjh.controller;

import com.xjh.bo.AclUserBO;
import com.xjh.service.AclUserService;
import com.xjh.utils.resultutils.ResponseObj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author： 徐建华
 * @date： 2022/2/13
 * @description：
 */
@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private AclUserService aclUserService;

    /**
     * 获取当前登录用户（springSecurity）
     *
     * @param authentication	authentication
     * @return java.lang.Object
     * @method getCurrentUser
     * @author XuJianHua
     * @date 2022/7/26 13:43
     * @description
     */
    @RequestMapping("/getCurrentUser")
    public Object getCurrentUser(Authentication authentication) {
        return authentication.getPrincipal();
    }

    /**
     * 查询所有用户
     *
     * @return com.xjh.utils.resultutils.ResponseObj
     * @method queryAll
     * @author XuJianHua
     * @date 2022/7/26 13:42
     * @description
     */
    @GetMapping("/list")
    public ResponseObj queryAll() {
        List<AclUserBO> pageModel = aclUserService.queryAll();
        ResponseObj responseObj = new ResponseObj();
        return responseObj.ok(pageModel);
    }


}
